package cn.edu.scau.cmi.zhangmingxing.composite.safe;

import java.util.HashSet;
import java.util.Set;

public class SafeComposite  extends SafeComponent{

	
	private String name=null;
	
	private Set<SafeComponent> children=new HashSet<SafeComponent>();

	@Override
	public String doSomething() {
		children.forEach(str->str.doSomething());
		return "我是安全性组合模式中的组合组件";
	}
	public String toString() {
		return name;
	}
	@Override
	public SafeComponent getParent() {
		return this.getParent();
	}
	
	
	public SafeComponent addChild(SafeComponent child){
		children.add(child);
		return this;
	}
	
	
	
	public SafeComponent removeChild(SafeComponent child){
		children.remove(child);
		return this;
	}
	
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<SafeComponent> getChildren() {
		return children;
	}

	public void setChildren(Set<SafeComponent> children) {
		this.children = children;
	}


}
